<?php
/**
 * BaseService
 * @copyright (c) 2011-2020, Hangzhou DOJI Tech Co., Ltd.
 * This is NOT a freeware, use is subject to license terms.
 * @package BsaeService.php
 * @link https://www.tingjunapp.com/
 * @author wujun@lanqb.cn
 * @: BaseService.php 310000 2020-11-06 15:13:27 $
 * */

namespace App\Services;

use App\Consts\ExceptionCode;
use App\Consts\GlobalConst;

class BaseService extends Service
{

    /**
     * @param $targetId
     * @return int
     */
    public function getTableNumber($targetId)
    {
        return sprintf('%u', crc32($targetId)) % GlobalConst::DATABASE_TABLE_NUM;
    }

    /**
     * 异常抛出
     * @param int $code
     * @param string $message
     * @return bool
     * @throws \Exception
     */
    public function throwError($code = ExceptionCode::ILLEGAL_PARAMETER, $message = '')
    {
        return ErrorService::throwError($code, $message);
    }


}
